//
//  BN_ChatHelperTest.m
//  BabyNow
//
//  Created by 闫建刚 on 14-5-12.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "XCTestAsync.h"
#import "BN_ChatHelper.h"

@interface BN_ChatHelperTest : XCTestCase
{
    BN_ChatHelper *helper_;
}

@end

@implementation BN_ChatHelperTest

- (void)setUp
{
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
    helper_ = [[BN_ChatHelper alloc]init];
}

- (void)tearDown
{
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
    helper_ = nil;
}


- (void)xctAssertNil:(NSString *)errorMsg{
    XCTAssertNil(errorMsg);
}

- (void)xcAsyncSuccess{
    XCAsyncSuccess();
}

// 测试查询联系人列表
- (void)testQueryChatPersonListAsync{
     __weak typeof(self) weakSelf = self;
    [helper_ queryChatPersonList:^(id result, NSString *errMsg) {
        if (errMsg) {
            [weakSelf xctAssertNil:errMsg];
        }else{
            NSLog(@"联系人列表：%@",result);
            [weakSelf xcAsyncSuccess];
        }
    }];
}

// 测试查询聊天会话
- (void)testQueryChatListAsync{
    __weak typeof(self) weakSelf = self;
    [helper_ queryChatList:^(id result, NSString *errMsg) {
        if (errMsg) {
            [weakSelf xctAssertNil:errMsg];
        }else{
            NSLog(@"聊天会话列表：%@",result);
            [weakSelf xcAsyncSuccess];
        }
    }];
}


// 测试查询聊天详情
- (void)testQueryChatDetailListAsync{
    NSString *userId = @"2";
     __weak typeof(self) weakSelf = self;
    helper_.queryChatDetailCompleteHandler = ^(id result,NSString *errMsg){
        if (errMsg) {
            [weakSelf xctAssertNil:errMsg];
        }else{
            NSLog(@"聊天详情会话列表：%@",result);
            [weakSelf xcAsyncSuccess];
        }
    };
    [helper_ refreshChatDetailListWithUserId:userId];
}

// 测试发送聊天信息
- (void)testSendChatContentAsync{
     NSString *userId = @"2";
     NSString *chatCont = @"hello parent 2";
     __weak typeof(self) weakSelf = self;
    [helper_ sendChatContentWithUserId:userId chatContent:chatCont completeHandler:^(id result, NSString *errMsg) {
        NSLog(@"聊天信息发送结果:%@",errMsg);
        [weakSelf xcAsyncSuccess];
    }];
}


@end
